package com.xxd.spring.boot.demo.zhuhongbing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Grade;
import com.xxd.spring.boot.demo.zhuhongbing.mapper.GradeMapper;
import com.xxd.spring.boot.demo.zhuhongbing.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GradeServiceImpl implements GradeService {
    @Autowired
    private GradeMapper gradeMapper;
    @Override
    public int add(Grade grade){
        int insert=gradeMapper.insert(grade);
        return insert;
    }

    @Override
    public int update(Grade grade) {
        return gradeMapper.updateById(grade);
    }

    @Override
    public int delete(int id) {
        return gradeMapper.deleteById(id);
    }

    @Override
    public IPage<Grade> listpage(Page page, Map<String, Object> parama) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.setEntity(parama);
        Page resPage=gradeMapper.selectPage(page,queryWrapper);
        return resPage;
    }

    @Override
    public List<Grade> list(Map<String, Object> parama) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.setEntity(parama);
        return gradeMapper.selectList(queryWrapper);
    }
}
